<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="str" uri="/WEB-INF/config/tld/string-util.tld" %>
<jsp:include page="../include/mainheader.jsp" />
<script type="text/javascript" src="<c:url value='/htmlRes/js/high_chart/highcharts.js'/>"></script>
<script type="text/javascript" src="<c:url value='/htmlRes/js/datepicker/jquery.ui.core.js'/>"></script>
<script type="text/javascript" src="<c:url value='/htmlRes/js/datepicker/jquery.ui.datepicker.js'/>"></script>
<script type="text/javaScript">
<!--
	$(document).ready(function(){
		$('.graph_box').each(function(index){
			var charId = $(this).attr('id');
			if($('#'+charId).html() != ""){
				var chartData = eval("("+$('#'+charId).html()+")");
				$('#'+charId).highcharts(chartData);
			}else{
				$('#'+charId).html("데이터가 없습니다.");
				$('#'+charId).css("text-align", "center");
				$('#'+charId).css("padding", "30px 0 0 0");
			}
		});
		
		$( "#searchSdate" ).datepicker();
		$( "#searchEdate" ).datepicker();
	});
	
	function searchForm(){
		$('#listForm').attr('action', '<c:url value="/main.do"/>');
		$('#listForm').submit();
	}
-->
</script>
<!-- contents s -->
<div class="container" id="container">
	<span class="round lt">&nbsp;</span>
	<span class="round rt">&nbsp;</span>
	<span class="round lb">&nbsp;</span>
	<span class="round rb">&nbsp;</span>
	<div class="container_area">
		<!--<h2 class="tit_h2">오수/전력 사용량</h2>-->
			<jsp:include page="../include/navi.jsp" />
			<span class="ico_print"><a href="#print"  onclick="printPage('<c:url value="/common/printView.do" />');return false;"><img src="/htmlRes/images/ico_print.jpg" alt="인쇄버튼"></a></span>
			<div class="content_wrap">
				<div class="con_left">
					<h2 class="tit_h2">현장 정보</h2>
					<div class="table_wrap">
						<table summary="현장 정보 입니다" class="table_list">
							<caption>현장 정보</caption>
							<colgroup> <!-- D : col width로 테이블 넓이 조절 -->
								<col width="20%" />
								<col width="25%" />
								<col width="25%" />
								<col width="30%" />
							</colgroup>
							<thead>
								<tr>
									<th scope="col">권역</th>
									<th scope="col">현장명</th>
									<th scope="col">시설용량<br />(㎥/일)</th>
									<th scope="col">담당자</th>
								</tr>
							</thead>
							<tbody>
							<c:set var="zoneKey" value="" />
							<c:forEach var="mlist" items="${mainInfo }">
								<tr>
									<c:if test="${zoneKey ne mlist.codeKey }">
										<td rowspan="${mlist.areaCnt }" class="bdR">${mlist.codeName }<br />권역</td>
									</c:if>
									<td>${mlist.areaName }</td>
									<td>${mlist.areaCapa }</td>
									<td>
										<c:if test="${not empty mlist.userName }">
											<c:set var="userHpArray" value="${str:getTelArray(mlist.userHp) }" />
											${mlist.userName }<br />(${userHpArray[0]}-${userHpArray[1]}-${userHpArray[2]})
										</c:if>
									</td>
								</tr>
								<c:set var="zoneKey" value="${mlist.codeKey }" />
							</c:forEach>
							</tbody>
						</table>
					</div>

					<h2 class="tit_h2">현장 관리</h2>
					<dl class="zone_management">
						<c:set var="zoneKey" value="" />
						<c:set var="totalZoneCnt" value="0" />
						<c:set var="totalAdminCnt" value="0" />
						<c:set var="totalZoneAdminCnt" value="0" />
						<c:forEach var="result" items="${mainInfo }">
							<c:if test="${zoneKey ne result.codeKey }">
								<c:set var="totalZoneCnt" value="${totalZoneCnt+result.areaCnt }" />
								<c:set var="totalAdminCnt" value="${totalAdminCnt+result.adminCnt }" />
								<c:set var="totalZoneAdminCnt" value="${totalZoneAdminCnt+result.zadminCnt }" />
								<dt>${result.codeName }권역</dt>
								<dd>${result.areaCnt } 개소</dd>
								<dt>관리인원</dt>
								<dd class="large">${result.adminCnt } 명 (팀장 ${result.zadminCnt } 명)</dd>
							</c:if>
							<c:set var="zoneKey" value="${result.codeKey }" />
						</c:forEach>
						<dt class="zone_point">합계</dt>
						<dd class="zone_point">${totalZoneCnt } 개소</dd>
						<dt class="zone_point">관리인원</dt>
						<dd class="large zone_point">${totalAdminCnt } 명 (팀장 ${totalZoneAdminCnt } 명)</dd>
					</dl>
					
				</div><!--//con_left-->

				<div class="con_right">
					<div class="srch_wrap">
						<form name="listForm" id="listForm" method="post" action="<c:url value='/main.do'/>">
							<fieldset>
								<legend>키워드 검색 조회 영역</legend>
								<select id="searchCodeKey" name="searchCodeKey" title="권역을 선택하세요" onchange="searchForm();return false;">
									<c:forEach var="resultZone" items="${zoneList }">
										<option value="${resultZone.scc_code_key }" <c:if test="${resultZone.scc_code_key eq mainVO.searchCodeKey }">selected="selected"</c:if>>${resultZone.scc_code_name }[${resultZone.scc_zone_aname }]</option>
									</c:forEach>
								</select>
								<label for="searchSdate">기간 </label><input type="text" id="searchSdate" name="searchSdate" value="${mainVO.searchSdate }"/> - <input type="text" id="searchEdate" name="searchEdate" value="${mainVO.searchEdate }">
								<a href="<c:url value='/main.do'/>" onclick="searchForm();return false;" class="btn_srch">검색</a>
							</fieldset>
						</form>
					</div>
					<span class="view_all"><a href="/mainChartAll.do">전체보기</a></span>
					<div class="graph_area">
						<c:if test="${not empty chartInfoList }">
						<c:forEach var="chartInfo" items="${chartInfoList }" varStatus="status">
							<div class="graph_header"></div>
							<c:if test="${chartInfo.unusualYn eq 'Y' or empty chartInfo.unusualYn}"><span class="green">보통${chartInfo.unusualYn}</span></c:if>
							<c:if test="${chartInfo.unusualYn eq 'N'}"><span class="red">심각</span></c:if>
							<div id="waterQualityChart${status.count}" class="graph_box">${chartInfo.waterQualityChart }</div>
						</c:forEach>
						</c:if>
						<c:if test="${empty chartInfoList }">
							<div class="graph_header"></div>
							<div id="waterQualityChart" class="graph_box"></div>
						</c:if>
					</div><!--//graph_area-->

				</div><!--//con_right-->
				
			</div><!--//content_wrap-->
	
	</div><!--//container_area-->
</div>
<!-- contents e -->
<jsp:include page="../include/footer.jsp" />